home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / fractal / fdesi313 / fdes13s / fdesplot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-01  |  20.7 KB  |  711 lines

  1.  
  2. #include <float.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <graphics.h>
  6. #include <conio.h>
  7. #include <dos.h>
  8. #include "fdestria.h"
  9. #include "fdesign.h"
  10. #include "fdesequa.h"
  11. #include "fdesfile.h"
  12. #include "fdesmenu.h"
  13. #include "fdesmous.h"
  14. #include "fdeshres.h"
  15. #include "fdesvirt.h"
  16.  
  17. #define plot_small_left 420
  18. #define plot_small_bottom 140
  19. #define CONV_ITS 100            /* iterations required for convergence */
  20.  
  21. int pal_switch;
  22. int plot_type;                  /* types are:   0 big 16 color
  23.                                                 1 small 16 color
  24.                                                 2 big 256 color
  25.                                                 3 big 256 color hi-res
  26.                                                 4 virtual big 1000 x 1500
  27.                                                 5 FRACTINT ifs screen size
  28.                                                 6 16 color w/increment
  29.                                                 */
  30. int last_plot_type = 0;
  31. int IFS_changed;
  32. float x,y;
  33. float xscale,yscale,xoffset,yoffset,maxx,maxy;
  34.  
  35. typedef struct {
  36.    float a,b,e,c,d,f,p;
  37.    } one_ifs;
  38.  
  39. one_ifs var[MAXFUNC];
  40. float *fv;
  41.  
  42. int n;
  43. unsigned char randmap[32768];
  44.  
  45. /************************************************************************
  46.         PLOT SOME POINTS USING THE IFS CODES
  47. ************************************************************************/
  48. void plotabunch(int howmany)
  49. {
  50. int m,j,k;
  51. float pk,newx,newy;
  52.  
  53.         k = 0;
  54.     for (m=0; m<howmany; m++) {
  55.       k = randmap[rand()];
  56.  
  57. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  58. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  59.  
  60.       fv = &var[k].a;
  61.       asm {
  62.          les   bx,[fv];
  63.          fld   es:dword ptr[bx];
  64.          add   bx,4;
  65.          fmul  dword ptr[x];
  66.          fld   es:dword ptr[bx];
  67.          add   bx,4;
  68.          fmul  dword ptr[y];
  69.          faddp st(1),st;
  70.          fadd  es:dword ptr[bx];
  71.          add   bx,4;
  72. /*         fstp  dword ptr[newx];   */
  73.  
  74.          fld   es:dword ptr[bx];
  75.          add   bx,4;
  76.          fmul  dword ptr[x];
  77.          fld   es:dword ptr[bx];
  78.          add   bx,4;
  79.          fmul  dword ptr[y];
  80.          faddp st(1),st;
  81.          fadd  es:dword ptr[bx];
  82.          add   bx,4;
  83. /*         fstp  dword ptr[newy];    */
  84.          fstp  dword ptr[y];
  85.          fstp  dword ptr[x];
  86.       };
  87.  
  88. /*      x = newx;
  89.       y = newy;
  90. */
  91.       putpixel((int)x,(int)y,colors[k%MAXCOLORS_]);
  92.     }
  93. }
  94. void plotabunch16(int howmany)
  95. {
  96. int m,j,k;
  97. float pk,newx,newy;
  98.  
  99.         k = 0;
  100.     for (m=0; m<howmany; m++) {
  101.       k = randmap[rand()];
  102.  
  103. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  104. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  105.  
  106.       fv = &var[k].a;
  107.       asm {
  108.          les   bx,[fv];
  109.          fld   es:dword ptr[bx];
  110.          add   bx,4;
  111.          fmul  dword ptr[x];
  112.          fld   es:dword ptr[bx];
  113.          add   bx,4;
  114.          fmul  dword ptr[y];
  115.          faddp st(1),st;
  116.          fadd  es:dword ptr[bx];
  117.          add   bx,4;
  118. /*         fstp  dword ptr[newx];   */
  119.  
  120.          fld   es:dword ptr[bx];
  121.          add   bx,4;
  122.          fmul  dword ptr[x];
  123.          fld   es:dword ptr[bx];
  124.          add   bx,4;
  125.          fmul  dword ptr[y];
  126.          faddp st(1),st;
  127.          fadd  es:dword ptr[bx];
  128.          add   bx,4;
  129. /*         fstp  dword ptr[newy];    */
  130.          fstp  dword ptr[y];
  131.          fstp  dword ptr[x];
  132.       };
  133.  
  134. /*      x = newx;
  135.       y = newy;
  136. */
  137.                 putpixel((int)x,(int)y,(getpixel((int)x,(int)y)+1)%maxcolor);
  138.     }
  139. }
  140. void plotabunchs(int howmany)
  141. {
  142. int m,j,k;
  143. float pk,newx,newy;
  144. int temp_x, temp_y;
  145.  
  146.         k = 0;
  147.     for (m=0; m<howmany; m++) {
  148.       k = randmap[rand()];
  149. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  150. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  151.  
  152.       fv = &var[k].a;
  153.       asm {
  154.          les   bx,[fv];
  155.          fld   es:dword ptr[bx];
  156.          add   bx,4;
  157.          fmul  dword ptr[x];
  158.          fld   es:dword ptr[bx];
  159.          add   bx,4;
  160.          fmul  dword ptr[y];
  161.          faddp st(1),st;
  162.          fadd  es:dword ptr[bx];
  163.          add   bx,4;
  164. /*         fstp  dword ptr[newx];   */
  165.  
  166.          fld   es:dword ptr[bx];
  167.          add   bx,4;
  168.          fmul  dword ptr[x];
  169.          fld   es:dword ptr[bx];
  170.          add   bx,4;
  171.          fmul  dword ptr[y];
  172.          faddp st(1),st;
  173.          fadd  es:dword ptr[bx];
  174.          add   bx,4;
  175. /*         fstp  dword ptr[newy];    */
  176.          fstp  dword ptr[y];
  177.          fstp  dword ptr[x];
  178.       };
  179.  
  180. /*      x = newx;
  181.       y = newy;
  182. */
  183.                 temp_x = (int)x;
  184.                 temp_y = (int)y;
  185.                 if ((temp_x >= plot_small_left) && (temp_y < plot_small_bottom))
  186.                         putpixel(temp_x,temp_y,colors[k%MAXCOLORS_]);
  187.     }
  188. }
  189. /*
  190. void plotabunch_inc(int howmany)
  191. {
  192. int m,j,k;
  193. int oldpixel;
  194. float pk,newx,newy;
  195. float screenx, screeny;
  196.  
  197.         k = 0;
  198.     for (m=0; m<howmany; m++) {
  199.       k = randmap[rand()];
  200.  
  201. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  202. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  203.  
  204.       fv = &var[k].a;
  205.       asm {
  206.          les   bx,[fv];
  207.          fld   es:dword ptr[bx];
  208.          add   bx,4;
  209.          fmul  dword ptr[x];
  210.          fld   es:dword ptr[bx];
  211.          add   bx,4;
  212.          fmul  dword ptr[y];
  213.          faddp st(1),st;
  214.          fadd  es:dword ptr[bx];
  215.          add   bx,4;
  216. /*         fstp  dword ptr[newx];   */
  217.  
  218.          fld   es:dword ptr[bx];
  219.          add   bx,4;
  220.          fmul  dword ptr[x];
  221.          fld   es:dword ptr[bx];
  222.          add   bx,4;
  223.          fmul  dword ptr[y];
  224.          faddp st(1),st;
  225.          fadd  es:dword ptr[bx];
  226.          add   bx,4;
  227. /*         fstp  dword ptr[newy];    */
  228.          fstp  dword ptr[y];
  229.          fstp  dword ptr[x];
  230.       };
  231.  
  232. /*      x = newx;
  233.       y = newy;
  234. */
  235.                 screenx = x;
  236.                 screeny = y;
  237.         oldpixel = getpixel256(screenx,screeny);
  238.  
  239.                 if (oldpixel == 255) putpixel256(screenx, screeny, 1);
  240.                 else putpixel256(screenx, screeny, oldpixel+1);
  241.     }
  242. }
  243. */
  244. /*
  245.         virtual plot fractal plotter
  246. */
  247. void vplotabunch(int howmany)
  248. {
  249. int m,j,k;
  250. float pk,newx,newy;
  251.  
  252.         k = 0;
  253.     for (m=0; m<howmany; m++) {
  254.       k = randmap[rand()];
  255.  
  256. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  257. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  258.  
  259.       fv = &var[k].a;
  260.       asm {
  261.          les   bx,[fv];
  262.          fld   es:dword ptr[bx];
  263.          add   bx,4;
  264.          fmul  dword ptr[x];
  265.          fld   es:dword ptr[bx];
  266.          add   bx,4;
  267.          fmul  dword ptr[y];
  268.          faddp st(1),st;
  269.          fadd  es:dword ptr[bx];
  270.          add   bx,4;
  271. /*         fstp  dword ptr[newx];   */
  272.  
  273.          fld   es:dword ptr[bx];
  274.          add   bx,4;
  275.          fmul  dword ptr[x];
  276.          fld   es:dword ptr[bx];
  277.          add   bx,4;
  278.          fmul  dword ptr[y];
  279.          faddp st(1),st;
  280.          fadd  es:dword ptr[bx];
  281.          add   bx,4;
  282. /*         fstp  dword ptr[newy];    */
  283.          fstp  dword ptr[y];
  284.          fstp  dword ptr[x];
  285.       };
  286.  
  287. /*      x = newx;
  288.       y = newy;
  289. */
  290.                 vputpixel((int)x,(int)y);
  291.     }
  292. }
  293. /*
  294.         *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  295.         Rescale IFS codes using xscale,xoffset,yscale,yoffset
  296.         *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  297.         rel = 0         if relative to original triangles
  298.         rel = 1         if relative to already scaled triangles
  299. */
  300. triangle ttriangle0;                    /* re-scaled reference triangle */
  301. triangle ttriangles[MAXFUNC];           /* re-scaled triangle data stores */
  302. void IFS_rescale(float xscale, float xoffset, float yscale, float yoffset, int rel)
  303. {
  304. int i,j,k,m;
  305. unsigned int jj,kk;
  306. float pt,pk,newx,newy;
  307.  
  308.         /* Now generate scaled copies of the triangles using the just
  309.            computed scale and offset factors */
  310.         if (rel == 0)
  311.         {
  312.                 for (i=0; i<3; i++)
  313.                 {
  314.                         ttriangle0.row[i] = triangle0.row[i]*yscale+yoffset;
  315.                         ttriangle0.col[i] = triangle0.col[i]*xscale+xoffset;
  316.                 }
  317.                 for (j=0; j<num_triangles; j++)
  318.                 {
  319.                         for (i=0; i<3; i++)
  320.                         {
  321.                                 ttriangles[j].row[i] = triangles[j].row[i]*yscale+yoffset;
  322.                                 ttriangles[j].col[i] = triangles[j].col[i]*xscale+xoffset;
  323.                         }
  324.                 }
  325.         } else
  326.         {
  327.                 for (i=0; i<3; i++)
  328.                 {
  329.                         ttriangle0.row[i] = ttriangle0.row[i]*yscale+yoffset;
  330.                         ttriangle0.col[i] = ttriangle0.col[i]*xscale+xoffset;
  331.                 }
  332.                 for (j=0; j<num_triangles; j++)
  333.                 {
  334.                         for (i=0; i<3; i++)
  335.                         {
  336.                                 ttriangles[j].row[i] = ttriangles[j].row[i]*yscale+yoffset;
  337.                                 ttriangles[j].col[i] = ttriangles[j].col[i]*xscale+xoffset;
  338.                         }
  339.                 }
  340.         }
  341.         /* Re-compute the IFS codes using the scaled triangles */
  342.         IFS_compute_all(num_triangles,ttriangles,&ttriangle0);
  343.         pt = 0;
  344.         for (i=0; i<num_triangles; i++)
  345.     {
  346.                 var[i].a = IFS[1+(i*7)];
  347.                 var[i].b = IFS[2+(i*7)];
  348.                 var[i].c = IFS[3+(i*7)];
  349.                 var[i].d = IFS[4+(i*7)];
  350.                 var[i].e = IFS[5+(i*7)];
  351.                 var[i].f = IFS[6+(i*7)];
  352.                 pt += IFS[7+(i*7)];
  353.         var[i].p = pt;
  354.     }
  355.    /*
  356.       setup random # map to IFS transformation 
  357.    */
  358.    memset(randmap,0,32767);
  359.    jj = 0;
  360.    for (i=0; i<num_triangles; i++)       /* fill in random number map */
  361.    {
  362.       kk = var[i].p*32767;
  363.       if (kk != jj)
  364.     memset(&randmap[jj],i,kk-jj);
  365.       jj = kk;
  366.    }
  367.  
  368.    /* do iterations so (x,y) is on new attractor */
  369.         k = 0;
  370.         for (m=0; m<CONV_ITS; m++) {
  371.       k = randmap[rand()];
  372.  
  373. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  374. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  375.  
  376.       fv = &var[k].a;
  377.       asm {
  378.          les   bx,[fv];
  379.          fld   es:dword ptr[bx];
  380.          add   bx,4;
  381.          fmul  dword ptr[x];
  382.          fld   es:dword ptr[bx];
  383.          add   bx,4;
  384.          fmul  dword ptr[y];
  385.          faddp st(1),st;
  386.          fadd  es:dword ptr[bx];
  387.          add   bx,4;
  388. /*         fstp  dword ptr[newx];   */
  389.  
  390.          fld   es:dword ptr[bx];
  391.          add   bx,4;
  392.          fmul  dword ptr[x];
  393.          fld   es:dword ptr[bx];
  394.          add   bx,4;
  395.          fmul  dword ptr[y];
  396.          faddp st(1),st;
  397.          fadd  es:dword ptr[bx];
  398.          add   bx,4;
  399. /*         fstp  dword ptr[newy];    */
  400.          fstp  dword ptr[y];
  401.          fstp  dword ptr[x];
  402.       };
  403.  
  404. /*      x = newx;
  405.       y = newy;
  406. */
  407.     }
  408.  
  409. }
  410. /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  411.                 copy scaled triangles from ttriangle*
  412.                 to the input triangle array
  413.    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
  414. void triangles_use_temp(void)
  415. {
  416. int i,j;
  417.         for (i=0; i<3; i++)
  418.         {
  419.                 triangle0.row[i] = ttriangle0.row[i];
  420.                 triangle0.col[i] = ttriangle0.col[i];
  421.         }
  422.         for (j=0; j<num_triangles; j++)
  423.         {
  424.                 for (i=0; i<3; i++)
  425.                 {
  426.                         triangles[j].row[i] = ttriangles[j].row[i];
  427.                         triangles[j].col[i] = ttriangles[j].col[i];
  428.                 }
  429.         }
  430.         IFS_changed = 1;
  431. }
  432.  
  433.  
  434. /*
  435.         Compute the limits of the IFS codes by executing several iterations
  436.         and storing the min and max values.
  437. */
  438. void plotlimits(unsigned int scale_its)
  439. {
  440. int m,j,k,i;
  441. float pk,newx,newy,pt;
  442. float xmin,xmax,ymin,ymax;
  443. float *frac;                            /* not necessary */
  444. unsigned int jj,kk;
  445.  
  446.         area_scaled = 1.0;               /* zooming area scaling is 1.0 */
  447.         frac = IFS;
  448.     IFS_compute_all(num_triangles,triangles,&triangle0);
  449.  
  450.     n = frac[0];
  451.         pt = 0;
  452.     for (i=0; i<n; i++)
  453.     {
  454.         var[i].a = frac[1+(i*7)];
  455.         var[i].b = frac[2+(i*7)];
  456.         var[i].c = frac[3+(i*7)];
  457.         var[i].d = frac[4+(i*7)];
  458.         var[i].e = frac[5+(i*7)];
  459.         var[i].f = frac[6+(i*7)];
  460.         pt += frac[7+(i*7)];
  461.         var[i].p = pt;
  462.     }
  463.     x = 0.0;
  464.     y = 0.0;
  465.    /*
  466.       setup random # map to IFS transformation 
  467.    */
  468.    memset(randmap,0,32767);
  469.    jj = 0;
  470.    for (i=0; i<num_triangles; i++)       /* fill in random number map */
  471.    {
  472.       kk = var[i].p*32767;
  473.       if (kk != jj)
  474.           memset(&randmap[jj],i,kk-jj);
  475.       jj = kk;
  476.    }
  477.  
  478.    for (m=0; m<scale_its; m++) {
  479.         if (m==CONV_ITS) {
  480.                     ymax = (ymin = y);
  481.                     xmax = (xmin = x); }
  482.       k = randmap[rand()];
  483.  
  484. /*      newx = var[k].a * x + var[k].b * y + var[k].e; */
  485. /*      newy = var[k].c * x + var[k].d * y + var[k].f; */
  486.       fv = &var[k].a;
  487.       asm {
  488.          les   bx,[fv];
  489.          fld   es:dword ptr[bx];
  490.          add   bx,4;
  491.          fmul  dword ptr[x];
  492.          fld   es:dword ptr[bx];
  493.          add   bx,4;
  494.          fmul  dword ptr[y];
  495.          faddp st(1),st;
  496.          fadd  es:dword ptr[bx];
  497.          add   bx,4;
  498. /*         fstp  dword ptr[newx];   */
  499.  
  500.          fld   es:dword ptr[bx];
  501.          add   bx,4;
  502.          fmul  dword ptr[x];
  503.          fld   es:dword ptr[bx];
  504.          add   bx,4;
  505.          fmul  dword ptr[y];
  506.          faddp st(1),st;
  507.          fadd  es:dword ptr[bx];
  508.          add   bx,4;
  509. /*         fstp  dword ptr[newy];    */
  510.          fstp  dword ptr[y];
  511.          fstp  dword ptr[x];
  512.       };
  513.  
  514. /*      x = newx;
  515.       y = newy;
  516. */
  517.         if (m > CONV_ITS) {
  518.                         if (x<xmin) xmin = x;
  519.                         if (x>xmax) xmax = x;
  520.                         if (y<ymin) ymin = y;
  521.                         if (y>ymax) ymax = y; }
  522.     }
  523.     if ((plot_type == 0) || (plot_type == 2) || (plot_type == 3) || (plot_type == 6))
  524.         {
  525.                 /* set scaling here */
  526.                 if (xmax == xmin) xscale = 1;
  527.         else xscale = 0.95 * maxx / (xmax - xmin);
  528.                 if (ymax == ymin) yscale = 1;
  529.         else yscale = 0.95 * maxy / (ymax - ymin);
  530.                 if (xscale > yscale) xscale = yscale;
  531.                 else yscale = xscale;
  532.         xoffset = -((xmax+xmin)/2.0)*xscale + maxx/2.0;
  533.         yoffset = -((ymax+ymin)/2.0)*yscale + maxy/2.0;
  534.     }
  535.         else if (plot_type == 4)
  536.         {
  537.                 /* set scaling here */
  538.                 if (xmax == xmin) xscale = 1;
  539.         else xscale = 0.95 * VWIDTH / (xmax - xmin);
  540.                 if (ymax == ymin) yscale = 1;
  541.         else yscale = 0.95 * VHEIGHT / (ymax - ymin);
  542.                 if (xscale > yscale) xscale = yscale;
  543.                 else yscale = xscale;
  544.         xoffset = -((xmax+xmin)/2.0)*xscale + VWIDTH/2.0;
  545.         yoffset = -((ymax+ymin)/2.0)*yscale + VHEIGHT/2.0;
  546.         }
  547.         else if (plot_type == 1)
  548.         {
  549.                 /* set scaling for small plot in upper right corner */
  550.                 if (xmax == xmin) xscale = 1;
  551.         else xscale = 0.9 * (maxx - plot_small_left) / (xmax - xmin);
  552.                 if (ymax == ymin) yscale = 1;
  553.         else yscale = 0.9 * plot_small_bottom / (ymax - ymin);
  554.                 if (xscale > yscale) xscale = yscale;
  555.                 else yscale = xscale;
  556.         xoffset = -((xmax+xmin)/2.0)*xscale +
  557.             (plot_small_left + maxx)/2.0;
  558.         yoffset = -((ymax+ymin)/2.0)*yscale + plot_small_bottom/2.0;
  559.     }
  560.         else if (plot_type == 5)        /* FRACTINT screen size */
  561.         {
  562.                 /*
  563.                    Fractint's screen size is x=0 to x=16
  564.                    and y=-6 to y=6.
  565.                    approximately.
  566.                 */
  567.                 if (xmax == xmin) xscale = 1;
  568.         else xscale = 14.0 / (xmax - xmin);
  569.                 if (ymax == ymin) yscale = 1;
  570.                 else yscale = 10.0 / (ymax - ymin);
  571.                 if (xscale > yscale) xscale = yscale;
  572.                 else yscale = xscale;
  573.                 yscale = -yscale;
  574.                 xoffset = -(((xmin+xmax)/2.0)*xscale);
  575.                 yoffset = -(((ymin+ymax)/2.0)*yscale) + 5.0;
  576.         }
  577.  
  578.         /* scale relative to originally input triangles */
  579.         IFS_rescale(xscale,xoffset,yscale,yoffset,0);
  580.  
  581.         last_plot_type = plot_type;
  582. }
  583.  
  584. /************************************************************************
  585.         BIG PLOT: PLOT FRACTAL UNTIL MOUSE CLICK
  586.         SMALL PLOT: PLOT A SMALL # OF POINTS
  587. ************************************************************************/
  588. int doIFSrand(void)   /* plot_type are commented at top of this file */
  589. {
  590. int rcode;
  591. long count;
  592. mouse_state m;
  593. char sbuf[80];
  594.  
  595.         /* re-compute limits if new IFS or plot type changed */
  596.         if (IFS_changed || (last_plot_type != plot_type)) {
  597.                 if (plot_type == 1) {
  598.                         setfillstyle(SOLID_FILL,BLACK);
  599.                         bar(plot_small_left,0,maxx,plot_small_bottom);
  600.                         plotlimits(300);
  601.                 }
  602.                 else if ((plot_type == 0) || (plot_type == 6))
  603.                 {
  604.             putmsg(150,175,"Wait...Computing Plot limits",DARKGRAY,LIGHTCYAN);
  605.                         plotlimits(3000);
  606.                         clrmsg();
  607.                 }
  608.                 else if ((plot_type == 2) || (plot_type == 3))
  609.                 {
  610. /*
  611.             putmsg(150,175,"Wait...Computing Plot limits",0,128);
  612. */
  613.             plotlimits(3000);
  614. /*
  615.             clrmsg();
  616. */
  617.         }
  618.                 else if (plot_type == 4)
  619.                 {
  620.             putmsg(150,175,"Scaling Main Display",DARKGRAY,LIGHTCYAN);
  621.                         delay(1000);
  622.                         clrmsg();
  623.                 }
  624.         IFS_changed = 0;
  625.         }
  626.         if (plot_type == 1)
  627.         {
  628.                 plotabunchs(10);                /* small plot plots 10 then */
  629.                                                 /* leaves. */
  630.                 return(0);
  631.         }
  632.         else if (plot_type == 0)
  633.         {
  634.                 do
  635.                 {
  636.                         plotabunch(500);        /* plots 500 points */
  637.                         rcode = mouse_press(&m);
  638.                 } while ((!rcode) && (!kbhit()));
  639.                 if (kbhit()) getch();
  640.                 return(rcode);
  641.         }
  642.     else if (plot_type == 6)
  643.         {
  644.                 do
  645.                 {
  646.                         plotabunch16(500);        /* plots 500 points */
  647.                         rcode = mouse_press(&m);
  648.                 } while ((!rcode) && (!kbhit()));
  649.                 if (kbhit()) getch();
  650.                 return(rcode);
  651.         }
  652.         else if (plot_type == 4)                /* virtual screen plot */
  653.         {
  654.                 putmsg_d(200,200,"          Virtual Plot Status         ",GREEN,WHITE);
  655.                 setfillstyle(SOLID_FILL,GREEN);
  656.                 bar(200,75,500,190);
  657.  
  658.                 count = 0;
  659.                 do
  660.                 {
  661.                         vplotabunch(5000);        /* plots 1500 points */
  662.                         count += 5000;
  663.  
  664.                         sprintf(sbuf,"Count = %ld",count);
  665.                         putmsg_d(200,50,sbuf,BLUE,WHITE);
  666.  
  667.                         setfillstyle(SOLID_FILL,RED);
  668.                         bar(200,75,min((300.0*count)/virt_target_size,300.0)+200,190);
  669.  
  670.                         rcode = mouse_press(&m);
  671.  
  672.                 } while ((!rcode) && (!kbhit()) && (count < virt_target_size));
  673.                 if (count >= virt_target_size)
  674.                         putmsg_d(290,130,"Plot Complete",RED,WHITE);
  675.                 if (kbhit()) getch();
  676.                 return(rcode);
  677.     }
  678. /*
  679.         else if ((plot_type == 2) || (plot_type == 3))
  680.         {
  681.                 pixel_max = 0;
  682.                 pal_switch = -2;                /* initial quantization */
  683.                 set_palette(pal_switch);
  684.                 do
  685.                 {
  686.                         plotabunch_inc(500);            /* plots 500 points */
  687.             if (-pixel_max < pal_switch)
  688.                         {
  689.                 if (pal_switch > -256)
  690.                                 {
  691.                     pal_switch -= 2;
  692.                                         set_palette(pal_switch);
  693.                                 }
  694.                         }
  695.                         mouse_get(&m);
  696.                         if (color_shift != m.row)
  697.                         {
  698.                                 color_shift = m.row;
  699.                 set_palette(pal_switch);
  700.                         };
  701.                         rcode = mouse_press(&m);
  702.                 } while ((!rcode) && (!kbhit()));
  703.                 if (kbhit()) getch();
  704.                 return(rcode);
  705.     }
  706. */
  707.     return(0);
  708. }
  709.  
  710. 
  711.